from pydantic_settings import BaseSettings
import os


class Settings(BaseSettings):
    ENVIRONMENT: str = os.getenv("ENVIRONMENT", "dev")

    # 数据库配置
    DB_HOST: str
    DB_PORT: int = 3306
    DB_NAME: str
    DB_USER: str
    DB_PASSWORD: str

    # 应用配置
    ALLOWED_ORIGINS: str
    DEBUG: bool = False
    APP_NAME: str = "Energy Predictor"
    VERSION: str = "1.0.0"

    class Config:
        ENVIRONMENT: str = os.getenv("ENVIRONMENT", "dev")
        # 静态指定可能的 env 文件，Pydantic 会自动按顺序查找
        #env_file = [".env.dev", ".env.prod"]  # 先尝试开发环境，再尝试生产环境
        env_file = f".env.{ENVIRONMENT}";
        env_file_encoding = "utf-8"
        case_sensitive = False  # 环境变量不区分大小写


    @property
    def current_env_file(self):
        return f".env.{self.ENVIRONMENT}"


settings = Settings()